package cn.cxd.leetcode;

public class Leetcode713 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int res = 0;
        int tmp = 1;
        for (int left = 0; left < nums.length; ++left) {
            tmp *= nums[left];
            if (tmp < k) {
                ++res;
                for (int right = left + 1; right < nums.length;) {
                    tmp *= nums[right];
                    if (tmp < k) {
                        ++res;
                        ++right;
                    } else {
                        break;
                    }
                }
            }
            tmp = 1;
        }
        return res;
    }
}
